<?php

/**
 * @author Bart Hanssens <bart.hanssens@fedict.be>
 */


require_once('./eyeballs_db.inc');
require_once('./eyeballs_web.inc');
?>

<html>
<head>
<link rel="stylesheet" type="text/css" href="eyeballs.css"/>
<title>Happy Eyeballs Tester</title>
</head>
<body>
<h1>Happy Eyeballs Tester</h1>
<p>Small test page to check whether a browser switches between IPv6 and IPv4
in the same session.
<br/>
See also the <a href="http://en.wikipedia.org/wiki/Happy_Eyeballs">Happy Eyeballs article</a> on Wikipedia.
</p>
<p>Security devices may not like this, because the same cookie will be
received over different IP-addresses, which looks like session hijacking /
cookie stealing.</p>

<h2>Current</h2>
<table id="current" name="current">
<tr>
	<th>Cookie</th>
	<th>HTTPS</th>
	<th>IP address</th>
	<th>Forward</th>
	<th>Agent</th>
</tr>
<tr>
<?php
	$arr_current = array($cookie, $https, $ip, $forward, $agent);
	foreach($arr_current as $cell) {
		echo "\t<td>$cell</td>\n";
	}
?>
</tr>
</table>

<h2>Eyeballs</h2>
<p>Cookies served over different IP addresses.</p>
<table id="eyeballs">
<tr>
	<th>Cookie</th>
	<th>Agent</th>
	<th>IPs</th>
</tr>
<?php
	$arr_eyeballs = list_multiple_ips();
	foreach($arr_eyeballs as $row) {
		echo "<tr>\n";
		echo "\t<td><a href='eyeballs_session.php?cookie=".$row['cookie']."'>".$row['cookie']."</a></td>\n";
		echo "\t<td>".$row['agent']."</td>\n";
		echo "\t<td>".$row['ip']."</td>\n";
		echo "</tr>\n";
	}

?>
</table>

<h2>Connections</h2>
<p>List of last 100 connections.</p>
<table id="connections">
<tr>
	<th>Stamp</th>
	<th>Cookie</th>
	<th>HTTPS</th>
	<th>IP address</th>
	<th>Forward</th>
	<th>Agent</th>
</th>
</tr>
<?php
	$arr_cookies = list_all_connections();
	foreach($arr_cookies as $row) {
		echo "<tr>\n";
		echo "\t<td>".$row['stamp']."</td>\n";
		echo "\t<td>".$row['cookie']."</td>\n";
		echo "\t<td>".$row['https']."</td>\n";
		echo "\t<td>".$row['ip']."</td>\n";
		echo "\t<td>".$row['forward']."</td>\n";
		echo "\t<td>".$row['agent']."</td>\n";
		echo "</tr>\n";
	}
?>
</table>

</body>
</html>
